package com.lagou.dto;

import java.util.List;

public class Page<T> {
    private List<T> data;
    private int totalCount;
    private int since;
    private int limit;

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getSince() {
        return since;
    }

    public void setSince(int since) {
        this.since = since;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public int getCurPageNumber() {
        return (this.since/this.limit)+1;
    }

    public int getTotalPageNumber() {
        return (this.totalCount/this.limit) + 1;
    }

    public int getPrevSince() {
        return (this.since - this.limit < 0) ? this.since : (this.since - this.limit);
    }

    public int getNextSince() {
        return (this.since + this.limit >= this.totalCount) ? this.since : (this.since + this.limit);
    }


    public Page(List<T> data, int totalCount) {
        this.data = data;
        this.totalCount = totalCount;
    }

    public Page(List<T> data, int totalCount, int since, int limit) {
        this.data = data;
        this.totalCount = totalCount;
        this.since = since;
        this.limit = limit;
    }
}
